package com.student.system.dao;

import com.student.system.entity.Admin;
import com.student.system.entity.Studentregister;
import com.student.system.service.AdminService;
import com.student.system.utils.C3P0Untils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class AdminDao {
    private static QueryRunner queryRunner=new QueryRunner(C3P0Untils.getDataSource());

    public static Admin select(String username, String password) throws SQLException {
        String sql = "select * from `admin` where username=? and password=?";
        return queryRunner.query(sql,new BeanHandler<>(Admin.class),username,password);
    }

    public Admin findByusername(String username) throws SQLException {
        String sql = "select * from `admin` where username=?";
        return queryRunner.query(sql,new BeanHandler<>(Admin.class),username);
    }
}
